Skip to content

fix: trigger full event lifecycle when keyboard is syncing on Android#1503

Merged
kirillzyusko merged 1 commit into
mainfrom
fix/full-lifecycle-events-on-android-when-sync-happens
Jun 19, 2026
Merged

fix: trigger full event lifecycle when keyboard is syncing on Android#1503
kirillzyusko merged 1 commit into
mainfrom
fix/full-lifecycle-events-on-android-when-sync-happens

Conversation

@kirillzyusko

@kirillzyusko kirillzyusko commented Jun 17, 2026

Copy link
Copy Markdown
Owner

📜 Description

Fixed an issue when closing a Modal triggers undesired scrolling in KeyboardAwareScrollView.

💡 Motivation and Context

The issue is because when Modal gets closed we dispatch only onMove/onEnd events. In KeyboardAwareScrollView in onStart method we have a lot of logic that computes current input position before keyboard animation, calculates offset etc. If we skip this stage, then onMove/onEnd may use values from previous keyboard interaction (so if keyboard was closed before and we scrolled for ~100px) we may scroll again, because values from onStart were not updated.

Technically that problem could be fixed in KeyboardAwareScrollView with additional conditions, but we use useKeyboardHandler hook in so many places/components, so if we would use this approach we potentially might need to replicate this fix in KeyboardAvoidingView and other components (and lib users would also need to do that if they use this hook in their projects).

So I think the correct fix is to fix inconsistency in native code.

Funny enough, but the new syncKeyboardPosition now becomes very similar to onKeyboardResized, especially since both functions are used in onApplyWindowInsets and I think that in the future these methods can be unified. Moreover the condition with detection keyboard resize or double keyboard position synchronization also can be unified and as a result we can make the codebase simpler. But this is the next step. First of all we need to merge/release this PR and keep an eye on possible bug reports about new bugs that caused by these changes 👀

Closes #1501 #1502

📢 Changelog

Android

  • send onStart event too from syncKeyboardPosition function;

🤔 How Has This Been Tested?

Tested manually on Pixel 7 Pro (API 36, real device).

📸 Screenshots (if appropriate):

Before After
telegram-cloud-document-2-5301142820508179758.mp4
telegram-cloud-document-2-5301142820508179759.mp4

📝 Checklist

  • CI successfully passed
  • I added new mocks and corresponding unit-tests if library API was changed

@kirillzyusko kirillzyusko self-assigned this Jun 17, 2026
@kirillzyusko kirillzyusko added 🐛 bug Something isn't working 🤖 android Android specific 🌎 modal Anything that involves Modal usage labels Jun 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📊 Package size report

Current size Target Size Difference
319489 bytes 319458 bytes 31 bytes 📈

@github-actions

Copy link
Copy Markdown
Contributor
  1. Misplaced Call to keepShadowNodesInSync
    Why: The call to context.keepShadowNodesInSync(eventPropagationView.id) in the onEnd method is incorrectly placed outside the conditional check for interactive keyboards. This could lead to unintended synchronization of shadow nodes, causing potential UI glitches or incorrect state management.
    Fix: Move this line inside the appropriate conditional block (e.g., when handling non-interactive keyboards) to ensure it only executes under the correct conditions.

  2. Incorrect Event Dispatching in syncKeyboardPosition
    Why: In the syncKeyboardPosition method, dispatching both Move and End events might lead to redundant or conflicting state updates in React Native's animated system, causing unexpected transitions or performance issues.
    Fix: Review and adjust the event dispatching logic to ensure it only sends necessary events based on the keyboard's visibility state.

@kirillzyusko kirillzyusko merged commit d77e9eb into main Jun 19, 2026
18 checks passed
@kirillzyusko kirillzyusko deleted the fix/full-lifecycle-events-on-android-when-sync-happens branch June 19, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 android Android specific 🐛 bug Something isn't working 🌎 modal Anything that involves Modal usage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KeyboardAvoidingView/Flatlist Scrolling When Modal Opened After TextInput Blurred Android.

1 participant